<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Device\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 装置组验证数据类
 */
class RdDeviceRodRequest extends FormRequest
{
    /**
     * 场景配置
     */
    protected array $scenes = [
        'index' => [
            'id',
            'name',
            'stand_id',
            'radar_num',
            'online',
            'created_at',
            'updated_at',
        ],
        'create' => [
            'name',
            'stand_id',
        ],
        'update' => [
            'name',
            'stand_id',
        ]
    ];

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            'id' => 'integer',
            //装置名称 验证
            'name' => 'max:100',
            //站点ID 验证
            'stand_id' => 'integer',
            //雷达数量 验证
            'radar_num' => 'integer',
            //在线状态 验证
            'online' => 'integer|in:1,2',

        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => 'ID',
            'name' => '装置名称',
            'stand_id' => '站点ID',
            'radar_num' => '雷达数量',
            'online' => '在线状态',
            'created_by' => '创建者',
            'updated_by' => '更新者',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',

        ];
    }

    public function messages(): array
    {
        return [
            'id.integer' => 'ID必须是整数',
            'name.required' => '必填装置名称',
            'name.max' => '装置名称长度不能超过100个字符',
            'stand_id.required' => '必填站点ID',
            'stand_id.integer' => '站点ID必须是整数',
            'radar_num.integer' => '雷达数量必须是整数',
            'online.integer' => '在线状态必须是整数',
            'online.in' => '在线状态只能是1(在线)或2(离线)',
            'created_by.required' => '必填创建者',
            'updated_by.required' => '必填更新者',

        ];
    }
}